<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
</head>
<body onload="window.print();">
<?php
require ("../CONFIG.config");
require (LIB . "common/common.class.php");
require (LIB . "common/db.class.php");
require ("../DB.config");

$clsDBConn = new DBConn();
CommonFunc::loadFile("model/Order.php");
$modOrder = new ModelOrder();
$request = CommonFunc::getRequestGET();
$orderid = $request['orderid'];
$order_arr = $modOrder->getOrderByID($orderid);
$cart_arr = $modOrder->getCart($order_arr[0]["cart_id"]);

$grandtotal=0;
$carthtml="";
$carthtml.=" <table width='100%' border='1'>";
$carthtml.=" <tbody>";
$carthtml.=" <tr>";
$carthtml.=" <th width='10%'>Product ID</th>";
$carthtml.=" <th width='50%'>Product Name</th>";
$carthtml.=" <th width='15%'>Unit Price(LKR)</th>";
$carthtml.=" <th width='10%'>Qty</th>";
$carthtml.=" <th width='15'>Total</th>";
$carthtml.=" </tr><tr>";

foreach($cart_arr as $cart){
	$carthtml.="<tr>";
	$carthtml.="<td align='center' width='16%'>".$cart['productid']."</td>";
	$carthtml.="<td align='center' width='16%'>".$cart['product_title']."</td>";
	$carthtml.="<td  align='center'width='16%'>".number_format($cart['price'],2)."</td>";
	$carthtml.="<td align='center' width='16%'>".$cart['quantity']."</td>";
	$carthtml.="<td align='center' width='16%'>".number_format($cart['quantity']* $cart['price'],2)."</td>";
	$grandtotal+= (int)$cart['quantity']* (int)$cart['price'];
}
$carthtml.=" </tr>";
$carthtml.=" <tr><td colspan='4' align='right'><strong>Sub Total </strong></td>";
$carthtml.=" <td width='20'>".number_format($grandtotal,2)."</td></tr>";
$carthtml.=" <tr><td colspan='4' align='right'><strong>Discount</strong></td>";
$carthtml.=" <td width='20'>"."------------------------"."</td></tr>";
$carthtml.=" <tr><td colspan='4' align='right'><strong>Taxes </strong></td>";
$carthtml.=" <td width='20'>"."------------------------"."</td></tr>";
$carthtml.=" <tr><td colspan='4' align='right'><strong>Delivery </strong></td>";
$carthtml.=" <td width='20'>"."------------------------"."</td></tr>";
$carthtml.=" <tr><td colspan='4' align='right'><strong>Total </strong></td>";
$carthtml.=" <td width='20'>"."------------------------"."</td></tr>"."</tbody></table>";

foreach ($order_arr as $order_entry)
{
?>

	<table border="0" width="80%" cellpadding="0" cellspacing="0" id="product-table">

            <tr><td class="hd"><p style="height:24px;">.</p></td><td class="s0">OFFICE SUPPLIES LK (PVT) LTD</td><td class="s1"></td><td class="s1"></td><td class="s1"></td><td class="s1"></td><td class="s2" rowspan="3" colspan="2">Invoice</td><td style="display:none;"></td><td class="s1"></td></tr>
		<tr>
			<th colspan="2" align="left" class="table-header-repeat line-left">&nbsp;</th>
		</tr>
            <tr>
			<td width="20%">Invoice No</td>
			<td width="60%">----------------------------------------</td>
		</tr>
            <tr>
			<td width="20%">Invoice Date</td>
			<td width="60%">----------------------------------------</td>
		</tr>
	        <?php 
				if($order_entry['order_date'] != "")
				{
			?>
		<tr>
			<td width="20%">Order Date</td>
			<td width="60%"><?php echo $order_entry['order_date']; ?></td>
		</tr>
	        <?php 
				}?>
              <?php
				if($order_entry['order_id'] != "")
				{
			?>
		<tr>
			<td width="20%">Order Date</td>
			<td width="60%"><?php echo $order_entry['order_id']; ?></td>
		</tr>
	        <?php
				}?>
            <tr>
			<td width="20%">Terms</td>
			<td width="60%">----------------------------------------</td>
		</tr>
            <tr>
			<td width="20%">Delivery</td>
			<td width="60%">----------------------------------------</td>
		</tr>

            

		
	</table>
<?php
}
?>
    <?php echo $carthtml . "<br />"; ?>
    <table><tr>

            <td class="s18">DIRECT ALL INQUIRIES TO:</td><td/><td/><td class="s18">MAKE ALL CHEQUES PAYABLE TO:</td><td/><td/><td/></tr><tr><td class="hd"><p style="height: 16px;">.</p></td><td class="s5"/><td class="s18">11 111 1111</td><td/><td/><td class="s18">OFFICE SUPPLIES LK (PVT) LTD</td><td/><td/><td/></tr><tr><td class="hd"><p style="height: 19px;">.</p></td><td class="s5"/><td class="s19"><a href="mailto:sales%40officesupplies.lk" style="color: rgb(0, 0, 255);" target="_blank">sales@officesupplies.lk</a></td><td/><td/><td/><td/><td/><td/></tr><tr><td class="hd"><p style="height: 16px;">.</p></td><td class="s5"/><td/><td/><td/><td/><td/><td/><td/></tr><tr><td class="hd"><p style="height: 19px;">.</p></td><td class="s20" colspan="8">Thank you for your Business with www.officesupplies.com</td>
        </tr>
    </table>
<div style="margin: 40px 0 0 0;" align="center">


<input type="button" name="btnClose" value="Close Window" onclick="javascript: window.close()" />
</div>
</body>
</html>